import Vue from 'vue'
import Vuex from 'vuex'
import http from "../../util/http";

Vue.use(Vuex)
const cinemaModule = {
    namespaced: true,
    state: {
        cinemaList: []
    },
    mutations: {
        setCinemaList(state,data) {
            state.cinemaList = data
        },
        clearCinemaList(state) {
            state.cinemaList = []
        }
    },
    actions: {
        getCinemaList(store,cityId) {
            //返回promise对象
            return http({
                url: `/gateway?cityId=${cityId}&ticketFlag=1&k=7820165`,
                method: 'GET',
                headers: {
                    'X-Host': 'mall.film-ticket.cinema.list',
                }
            }).then(res => {
                //响应的数据
                store.commit('setCinemaList',res.data.data.cinemas)
            })
        }
    }
}

export default cinemaModule